package com.virtualperson.enums;

/**
 * 任务状态枚举
 */
public enum TaskStatus {
    PENDING("排队中"),
    RUNNING("处理中"),
    SUSPENDED("挂起"),
    SUCCEEDED("执行成功"),
    FAILED("执行失败"),
    UNKNOWN("任务不存在或状态未知");

    private final String description;

    TaskStatus(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据状态字符串获取对应的枚举值
     * @param status 状态字符串
     * @return 对应的TaskStatus枚举值，如果未找到则返回UNKNOWN
     */
    public static TaskStatus fromString(String status) {
        if (status == null) {
            return UNKNOWN;
        }
        
        try {
            return TaskStatus.valueOf(status.toUpperCase());
        } catch (IllegalArgumentException e) {
            return UNKNOWN;
        }
    }
} 